import { Config } from "@/config/Config";
import { ErrorCode } from "@/config/ErrorCode";
import { DateUtil } from "@/engine/util/DateUtil";
import { HttpUtil } from "@/engine/util/HttpUtil";
import { Logger } from "@/engine/util/Logger";
import { Md5Helper } from "@/engine/util/Md5Helper";
import { UserModel } from "@/store/model/UserModel";
import { UIHelper } from "./UIHelper";

export class HttpClient {

    public static login(userName: string, pass: string, callback: Function = null) {
        let data: object = {
            "userName": userName,
            "pass": pass
        }
        if (Config.isConnectServer) {
            HttpUtil.request(Config.getHttpUrl() + "/login", data, (respData: object) => {
                Logger.log("HttpClient.login=", respData)
                UserModel.instance.token = respData["data"]["token"]
                UserModel.instance.login(userName, pass);
                callback && callback()
            })
        } else {
            UserModel.instance.token = "abcd"
            UserModel.instance.login(userName, pass);
            callback && callback()
        }
    }

    public static get_main_statistics_info(callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_main_statistics_info"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data

        }
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_main_statistics_info=", respData)
            callback && callback(respData["data"])
        })
    }


    public static get_account_list(pagenum: number, pagesize: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_account_list"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "pagenum": pagenum,
            "pagesize": pagesize,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_account_list==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_account_list=", respData)
            callback && callback(respData["data"])
        })
    }

    public static search_account(searchKey: string, searchValue: string, callback: Function) {
        let url: string = Config.getHttpUrl() + "/search_account"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchKey": searchKey,
            "searchValue": searchValue,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.search_account==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.search_account=resp", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_account_register(callback: Function) {
        let nowDate: Date = new Date()
        let startDate: Date = new Date(nowDate.getFullYear(), nowDate.getMonth(), 1)
        let url: string = Config.getHttpUrl() + "/get_account_register"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "startDate": +startDate.getTime(),
            "endDate": nowDate.getTime(),
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_account_register==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_account_register=resp", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_account_login(callback:Function){
        let nowDate: Date = new Date()
        let startDate: Date = new Date(nowDate.getFullYear(), nowDate.getMonth(), 1)
        let url: string = Config.getHttpUrl() + "/get_account_login"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "startDate": +startDate.getTime(),
            "endDate": nowDate.getTime(),
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_account_login==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_account_login=resp", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_account_keep(searchTime:Array<Date>, callback:Function){
        for (let i = 0; i < searchTime.length; i++) {
            searchTime[i].setHours(0)
            searchTime[i].setMinutes(0)
            searchTime[i].setSeconds(0)
        }
        let realSearchTime: Array<number> = [
            searchTime[0].getTime(),
            searchTime[1].getTime(),
        ]
        let url: string = Config.getHttpUrl() + "/get_account_keep"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchTime": realSearchTime
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_account_keep==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_account_keep=resp", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_server_list(callback: Function) {
        // let url: string = Config.getOnlineServer()
        // let param: object = {

        // }
        // HttpUtil.requestByForm(url, param, (respData: object) => {
        //     Logger.log("HttpClient.get_server_list=", respData)
        //     callback && callback(respData)
        // })

    }

    public static get_gm_server_status(callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_gm_server_status"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data

        }
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_gm_server_status=", respData)
            callback && callback(respData["data"])
        })
    }

    public static set_allserver_status(status: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/set_allserver_status"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "status": status
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data

        }
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.set_allserver_status=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_gameserver_status(gameType: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_gameserver_status"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "gameType": gameType,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data

        }
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_gameserver_status=", respData)
            callback && callback(respData["data"])
        })
    }

    public static set_gameserver_status(gameType: number, status: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/set_gameserver_status"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "status": status,
            "gameType": gameType,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data

        }
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.set_gameserver_status=", respData)
            callback && callback(respData["data"])
        })
    }



    public static get_user_list(pagenum: number, pagesize: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_user_list"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "pagenum": pagenum,
            "pagesize": pagesize,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_user_list==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_user_list=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_user_info(userid: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_user_info"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "userid": userid,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_user_info==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_user_info=", respData)
            callback && callback(respData["data"])
        })
    }

    public static charge_by_gm(userid: number, num: number, type: string, callback: Function) {
        let url: string = Config.getHttpUrl() + "/charge_by_gm"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "userid": userid,
            "num": num,
            "type": type
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.charge_by_gm==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.charge_by_gm=", respData)
            callback && callback(respData["data"])
        })
    }

    public static fengjin_user(userid: number, state: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/fengjin_user"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "userid": userid,
            "state": state,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.fengjin_user==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.fengjin_user=", respData)
            callback && callback(respData["data"])
        })
    }

    public static set_normal_daili(userid: number, lv: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/set_normal_daili"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "userid": userid,
            "lv": lv,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.set_normal_daili==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.set_normal_daili=", respData)
            callback && callback(respData["data"])
        })
    }

    public static set_qudao_daili(userid: number, qudaodaili: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/set_qudao_daili"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "userid": userid,
            "qudaodaili": qudaodaili,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.set_qudao_daili==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.set_qudao_daili=", respData)
            callback && callback(respData["data"])
        })
    }


    public static get_user_normal_daili_list(pagenum: number, pagesize: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_user_normal_daili_list"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "pagenum": pagenum,
            "pagesize": pagesize,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_user_normal_daili_list==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_user_normal_daili_list=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_invite_list(pagenum: number, pagesize: number, invite: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/req_invite_list"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "invite": invite,
            "pagenum": pagenum,
            "pagesize": pagesize
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.req_invite_list==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.req_invite_list=", respData)
            callback && callback(respData["data"])
        })
    }


    public static get_user_qudao_daili_list(pagenum: number, pagesize: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_user_qudao_daili_list"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "pagenum": pagenum,
            "pagesize": pagesize,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_user_qudao_daili_list==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_user_qudao_daili_list=", respData)
            callback && callback(respData["data"])
        })
    }

    public static game_date_charge_data(searchDate: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/game_date_charge_data"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.game_date_charge_data==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.game_date_charge_data=", respData)
            callback && callback(respData["data"])
        })
    }

    public static game_week_charge_data(searchDate: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/game_week_charge_data"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.game_week_charge_data==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.game_week_charge_data=", respData)
            callback && callback(respData["data"])
        })
    }

    public static game_month_charge_data(searchDate: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/game_month_charge_data"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.game_month_charge_data==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.game_month_charge_data=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_user_spend(searchDate: number, timetype: string, kind: string, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_user_spend"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
            "timetype": timetype,
            "kind": kind,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_user_spend==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_user_spend=", respData)
            callback && callback(respData["data"])
        })
    }


    public static update_system_setting(setting_key: string, setting_value: string, callback: Function = null) {
        let url: string = Config.getHttpUrl() + "/update_system_setting"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "setting_key": setting_key,
            "setting_value": setting_value,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.update_system_setting==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.update_system_setting=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_system_setting(setting_key: string, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_system_setting"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "setting_key": setting_key,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_system_setting==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_system_setting=", respData)
            callback && callback(respData["data"])
        })
    }



    public static get_choushui(callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_choushui"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_choushui==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_choushui=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_notice(callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_notice"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_notice==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_notice=", respData)
            callback && callback(respData["data"])
        })
    }


    public static get_gems_detail(searchDate: number, pagenum: number, pagesize: number, userid: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_gems_detail"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
            "pagenum": pagenum,
            "pagesize": pagesize,
            "userid": userid,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_gems_detail==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_gems_detail=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_coins_detail(searchDate: number, pagenum: number, pagesize: number, userid: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_coins_detail"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
            "pagenum": pagenum,
            "pagesize": pagesize,
            "userid": userid,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_coins_detail==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_coins_detail=", respData)
            callback && callback(respData["data"])
        })
    }


    public static get_meilis_detail(searchDate: number, pagenum: number, pagesize: number, userid: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_meilis_detail"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
            "pagenum": pagenum,
            "pagesize": pagesize,
            "userid": userid,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_meilis_detail==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_meilis_detail=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_daily_resource(callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_daily_resource"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_daily_resource==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_daily_resource=", respData)
            callback && callback(respData["data"])
        })
    }

    public static create_ziyou_room_template(roomObj: object, callback: Function) {
        let url: string = Config.getHttpUrl() + "/create_ziyou_room_template"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "roomObj": roomObj
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.create_ziyou_room_template==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.create_ziyou_room_template=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_ziyou_room_template(gameType: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_ziyou_room_template"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "gameType": gameType,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_ziyou_room==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_ziyou_room=", respData)
            callback && callback(respData["data"])
        })
    }

    public static delete_ziyou_room_template(id: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/delete_ziyou_room_template"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "id": id,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.delete_ziyou_room_template==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.delete_ziyou_room_template=", respData)
            callback && callback(respData["data"])
        })
    }

    public static fix_club_top(clubid: number, userid: number, key: string, value: number, dateStr: string, callback: Function = null) {
        let url: string = Config.getHttpUrl() + "/fix_club_top"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "clubid": clubid,
            "userid": userid,
            "key": key,
            "value": value,
            "dateStr": dateStr,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.fix_club_top==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.fix_club_top=", respData)
            callback && callback(respData["data"])
        })
    }

    public static kill_all_users() {
        let url: string = Config.getHttpUrl() + "/kill_all_users"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.kill_all_users==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.kill_all_users=", respData)
            // callback && callback(respData["data"])
        })
    }

    public static kill_users_by_game(gameType: number) {
        let url: string = Config.getHttpUrl() + "/kill_users_by_game"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "gameType": gameType,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.kill_users_by_game==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.kill_users_by_game=", respData)
            // callback && callback(respData["data"])
        })
    }

    public static get_zhanji(searchDate: number, pagenum: number, pagesize: number, userid: number, gameType: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_zhanji"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "searchDate": searchDate,
            "userid": userid,
            "pagenum": pagenum,
            "pagesize": pagesize,
            "gameType": gameType,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_zhanji==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_zhanji=", respData)
            callback && callback(respData["data"])
        })
    }

    public static get_zhanji_detail(gameResultId: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/get_zhanji_detail"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "gameResultId": gameResultId,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.get_zhanji_detail==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.get_zhanji_detail=", respData)
            callback && callback(respData["data"])
        })
    }

    public static unbind(userid: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/unbind"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "userid": userid,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.unbind==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.unbind=", respData)
            callback && callback(respData["data"])
        })
    }

    public static join_club_gm(userid: number, clubid: number, callback: Function) {
        let url: string = Config.getHttpUrl() + "/join_club_gm"
        let data: object = {
            "t": DateUtil.now(),
            "token": UserModel.instance.token,
            "userid": userid,
            "clubid": clubid,
        }
        let param: object = {
            "k": Md5Helper.getMd5_encrypt(JSON.stringify(data)),
            "data": data
        }
        Logger.log("HttpClient.join_club_gm==req", data)
        HttpUtil.request(url, param, (respData: object) => {
            Logger.log("HttpClient.join_club_gm=", respData)
            if (respData["code"] == ErrorCode.Code.Suc) {
                UIHelper.showMsg("添加成功")
            }
            callback && callback(respData["data"])
        })
    }
}